﻿using Microsoft.Web.WebView2.Wpf;
using RSModels;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace RSDesktop.Views.Popup
{
    /// <summary>
    /// MobileSimulation.xaml 的交互逻辑
    /// </summary>
    public partial class MobileSimulation : Window
    {
        public MobileSimulation(List<RSEvent> buffer, List<Position> positions, WebView2 webView2)
        {
            InitializeComponent();
            list.ItemsSource = rSEvents;
            Buffer = buffer;
            Positions = positions;
            WebView2 = webView2;
        }

        public List<RSEvent> Buffer { get; set; }

        public List<Position> Positions { get; set; }

        public WebView2 WebView2 { get; set; }

        readonly List<RSEvent> rSEvents = new()
        {
            new RSEvent()
            {
              Title="驾驶员打卡上班",
              Content="驾驶员：李四已打卡上班",
              EventTime="2021/9/1 05:16:17",
              CarID=13241,
              DriverID=35468716,
              CurrentLoad=0f,
              Lng=112.457078f,
              Lat=34.605378f,
            },
            new RSEvent()
            {
              Title="车辆已到达目的地",
              Content="车辆已经到达XX路XX小区，准备进行垃圾清运",
              EventTime="2021/9/1 05:32:41",
              CarID=13241,
              DriverID=35468716,
              CurrentLoad=0f,
              Lng=112.456416f,
              Lat=34.609102f,
            },
            new RSEvent()
            {
              Title="垃圾装车完毕",
              Content="XX路XX小区垃圾交付点清理完成",
              EventTime="2021/9/1 05:59:06",
              CarID=13241,
              DriverID=35468716,
              CurrentLoad=1.2f,
              Lng=112.457674f,
              Lat=34.609027f,
            },
            new RSEvent()
            {
              Title="车辆正在前往XX大学",
              Content="车辆正在前往XX大学",
              EventTime="2021/9/1 06:10:06",
              CarID=13241,
              DriverID=35468716,
              CurrentLoad=2.5f,
              Lng=112.456416f,
              Lat=34.609102f,
            },
            new RSEvent()
            {
              Title="测试",
              Content="将消息发给ID为13245的车辆",
              EventTime="2021/9/1 06:10:06",
              CarID=13245,
              DriverID=35468718,
              CurrentLoad=2.5f,
              Lng=112.457078f,
              Lat=34.605378f,
            },
        };

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (list.SelectedItem is RSEvent rS)
            {
                Buffer.Insert(0, rS);
            }
            else
                new TipWindow("提示", "请先选择要发送的内容").Show();
        }
    }
}
